var arr = [1, 2, 3, 4, 5, 4, 3, 4];
function findMaxthNum(arr) {
  var d = {};
  arr.forEach(k => !d[k] ? d[k] = 1 : d[k]++);
  return Object.keys(d).sort((a, b) => d[b] - d[a])[0];
}